home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / pd / netz / term / extras / source / gtlayout-source.lha / LT_Build.c < prev    next >
C/C++ Source or Header  |  1995-04-03  |  16KB  |  745 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. struct Window * __stdargs
  10. LT_Build(LayoutHandle *Handle,...)
  11. {
  12.     struct Window    *Result;
  13.     va_list      VarArgs;
  14.  
  15.     va_start(VarArgs,Handle);
  16.     Result = LT_BuildA(Handle,(struct TagItem *)VarArgs);
  17.     va_end(VarArgs);
  18.  
  19.     return(Result);
  20. }
  21.  
  22.  
  23. /*****************************************************************************/
  24.  
  25.  
  26. struct Window * LIBENT
  27. LT_BuildA(REG(a0) LayoutHandle *handle,REG(a1) struct TagItem *TagParams)
  28. {
  29.     LONG         left, top, width, height;
  30.     struct IBox     newBounds;
  31.     struct Menu    *menu        = NULL;
  32.     struct TagItem    *item;
  33.     LONG         placeLeft;
  34.     LONG         placeTop;
  35.     struct IBox     zoomBox;
  36.     struct IBox    *zoom;
  37.     LONG         i;
  38.     struct TextFont *font;
  39.     struct TagItem    *NewTags = NULL,*Tags;
  40.     BOOL          BlockParent = handle -> BlockParent,
  41.              SmartZoom = FALSE;
  42.     BOOL         MakeVisible = FALSE;
  43.     struct Window    *Parent = handle -> Parent;
  44.     STRPTR         title        = NULL;
  45.     struct IBox    *bounds     = NULL;
  46.     LONG         extraWidth    = 0,
  47.              extraHeight    = 0;
  48.     ULONG         IDCMP        = NULL;
  49.     UWORD         align        = 0;
  50.     WORD         MinX,
  51.              MinY,
  52.              MaxX,
  53.              MaxY;
  54.     BOOL         SizeGadget    = FALSE,
  55.              SizeBRight    = FALSE,
  56.              SizeBBottom    = FALSE;
  57.     ULONG         BorderBottom,
  58.              BorderRight;
  59.     struct Menu    *LocalMenu        = NULL;
  60.     struct TagItem    *LocalMenuTags        = NULL;
  61.     struct NewMenu    *LocalMenuTemplate    = NULL;
  62.  
  63.     if(!handle)
  64.         return(NULL);
  65.  
  66.     /* ALWAYS */
  67.     {
  68.         struct TagItem *TagList = (struct TagItem *)TagParams;
  69.  
  70.         while(item = NextTagItem(&TagList))
  71.         {
  72.             switch((ULONG)item -> ti_Tag)
  73.             {
  74.                 case LAWN_MenuTemplate:
  75.  
  76.                     LocalMenuTemplate = (struct NewMenu *)item -> ti_Data;
  77.                     break;
  78.  
  79.                 case LAWN_MenuTags:
  80.  
  81.                     LocalMenuTags = (struct TagItem *)item -> ti_Data;
  82.                     break;
  83.  
  84.                 case LAWN_FlushLeft:
  85.  
  86.                     handle -> FlushLeft = item -> ti_Data;
  87.                     break;
  88.  
  89.                 case LAWN_FlushTop:
  90.  
  91.                     handle -> FlushTop = item -> ti_Data;
  92.                     break;
  93.  
  94.                 case LAWN_TitleText:
  95.  
  96.                     title = (STRPTR)item -> ti_Data;
  97.                     break;
  98.  
  99.                 case LAWN_TitleID:
  100.  
  101.                     if(!handle -> LocaleHook)
  102.                         return(NULL);
  103.                     else
  104.                         title = (STRPTR)CallHookPkt(handle -> LocaleHook,handle,(APTR)item -> ti_Data);
  105.  
  106.                     break;
  107.  
  108.                 case LAWN_Bounds:
  109.  
  110.                     bounds = (struct IBox *)item -> ti_Data;
  111.                     break;
  112.  
  113.                 case LAWN_ExtraWidth:
  114.  
  115.                     extraWidth = item -> ti_Data;
  116.                     break;
  117.  
  118.                 case LAWN_ExtraHeight:
  119.  
  120.                     extraHeight = item -> ti_Data;
  121.                     break;
  122.  
  123.                 case LAWN_IDCMP:
  124.  
  125.                     IDCMP = item -> ti_Data;
  126.                     break;
  127.  
  128.                 case LAWN_AlignWindow:
  129.  
  130.                     align = item -> ti_Data;
  131.                     break;
  132.             }
  133.         }
  134.     }
  135.  
  136. #ifdef DO_MENUS
  137.     if(LocalMenuTags)
  138.     {
  139.         if(LocalMenu = LT_NewMenuTags(LAMN_Handle,handle,TAG_MORE,LocalMenuTags))
  140.         {
  141.             menu = LocalMenu;
  142.             handle -> IDCMP |= IDCMP_MENUPICK;
  143.         }
  144.         else
  145.             return(NULL);
  146.     }
  147.     else
  148.     {
  149.         if(LocalMenuTemplate)
  150.         {
  151.             if(LocalMenu = LT_NewMenuTemplate(handle -> Screen,handle -> TextAttr,handle -> AmigaGlyph,handle -> CheckGlyph,NULL,LocalMenuTemplate))
  152.             {
  153.                 menu = LocalMenu;
  154.                 handle -> IDCMP |= IDCMP_MENUPICK;
  155.             }
  156.             else
  157.                 return(NULL);
  158.         }
  159.     }
  160. #endif    // DO_MENUS
  161.  
  162.     if(!bounds)
  163.     {
  164.         LTP_GetDisplayClip(handle -> Screen,&newBounds . Left,&newBounds . Top,&newBounds . Width,&newBounds . Height);
  165.  
  166.         bounds = &newBounds;
  167.     }
  168.  
  169.     left = handle -> Screen -> WBorLeft;
  170.  
  171.     if(title)
  172.         top = handle -> Screen -> WBorTop + handle -> Screen -> Font -> ta_YSize + 1;
  173.     else
  174.         top = handle -> Screen -> WBorTop;
  175.  
  176.     BorderRight    = handle -> Screen -> WBorRight;
  177.     BorderBottom    = handle -> Screen -> WBorBottom;
  178.  
  179.     if(handle -> ResizeView)
  180.     {
  181.         if(handle -> ResizeView -> Special . List . ResizeY)
  182.             BorderBottom = LTP_GetSizeHeight(handle);
  183.         else
  184.         {
  185.             if(handle -> ResizeView -> Special . List . ResizeX)
  186.                 BorderRight = LTP_GetSizeWidth(handle);
  187.         }
  188.     }
  189.  
  190.     if(!handle -> FlushLeft)
  191.     {
  192.         left        += handle -> InterWidth;
  193.         BorderRight    += handle -> InterWidth;
  194.     }
  195.  
  196.     if(!handle -> FlushTop)
  197.     {
  198.         top        += handle -> InterHeight;
  199.         BorderBottom    += handle -> InterHeight;
  200.     }
  201.  
  202.     LTP_CreateGadgets(handle,bounds,left,top,left + BorderRight,top + BorderBottom);
  203.  
  204.     if(handle -> Failed)
  205.         return(NULL);
  206.  
  207.     width    = left + handle -> TopGroup -> Width + BorderRight;
  208.     height    = top + handle -> TopGroup -> Height + BorderBottom;
  209.  
  210.     if(handle -> ResizeView)
  211.     {
  212.         WORD GlyphWidth,GlyphHeight;
  213.  
  214.         MaxX = MinX = width;
  215.         MaxY = MinY = height;
  216.  
  217.         if(handle -> ResizeView -> Special . List . ResizeX)
  218.             MaxX = handle -> Screen -> Width;
  219.  
  220.         if(handle -> ResizeView -> Special . List . ResizeY)
  221.         {
  222.             MaxY = handle -> Screen -> Height;
  223.  
  224.             SizeBBottom = TRUE;
  225.         }
  226.         else
  227.             SizeBRight = TRUE;
  228.  
  229.         SizeGadget = TRUE;
  230.  
  231.         if(handle -> ResizeView -> Special . List . TextAttr)
  232.         {
  233.             GlyphWidth    = handle -> ResizeView -> Special . List . FixedGlyphWidth;
  234.             GlyphHeight    = handle -> ResizeView -> Special . List . FixedGlyphHeight;
  235.         }
  236.         else
  237.         {
  238.             GlyphWidth    = handle -> GlyphWidth;
  239.             GlyphHeight    = handle -> RPort . TxHeight;
  240.         }
  241.  
  242.         if(handle -> ResizeView -> Special . List . MinChars && handle -> ResizeView -> Special . List . MinChars < handle -> ResizeView -> Chars)
  243.             MinX -= GlyphWidth * (handle -> ResizeView -> Chars - handle -> ResizeView -> Special . List . MinChars);
  244.  
  245.         if(handle -> ResizeView -> Special . List . MinLines && handle -> ResizeView -> Special . List . MinChars < handle -> ResizeView -> Lines)
  246.             MinY -= GlyphHeight * (handle -> ResizeView -> Lines - handle -> ResizeView -> Special . List . MinLines);
  247.     }
  248.     else
  249.     {
  250.         MaxX = MinX = width;
  251.         MaxY = MinY = height;
  252.     }
  253.  
  254.     if(align & ALIGNF_LEFT)
  255.         placeLeft = 0;
  256.     else
  257.     {
  258.         if(align & ALIGNF_RIGHT)
  259.             placeLeft = bounds -> Width - (width + extraWidth);
  260.         else
  261.             placeLeft = (bounds -> Width - (width + extraWidth)) / 2;
  262.     }
  263.  
  264.     if(align & ALIGNF_TOP)
  265.         placeTop = 0;
  266.     else
  267.     {
  268.         if(align & ALIGNF_BOTTOM)
  269.             placeTop = bounds -> Height - (height + extraHeight);
  270.         else
  271.             placeTop = (bounds -> Height - (height + extraHeight)) / 2;
  272.     }
  273.  
  274.     if(align & ALIGNF_EXTRA_LEFT)
  275.         placeLeft += extraWidth;
  276.     else
  277.     {
  278.         if(!(align & ALIGNF_EXTRA_RIGHT))
  279.             placeLeft += extraWidth / 2;
  280.     }
  281.  
  282.     if(align & ALIGNF_EXTRA_TOP)
  283.         placeTop += extraHeight;
  284.     else
  285.     {
  286.         if(!(align & ALIGNF_EXTRA_BOTTOM))
  287.             placeTop += extraHeight / 2;
  288.     }
  289.  
  290.     placeLeft    += bounds -> Left;
  291.     placeTop    += bounds -> Top;
  292.  
  293.     if(placeLeft < 0)
  294.         placeLeft = 0;
  295.  
  296.     if(placeTop < 0)
  297.         placeTop = 0;
  298.  
  299.     zoom = NULL;
  300.  
  301.     handle -> AutoRefresh = TRUE;
  302. #ifdef DO_CLONING
  303.     if(handle -> CloneExtra)
  304.     {
  305.         placeLeft    = 0;
  306.         placeTop    = handle -> CloneExtra -> Screen -> BarHeight + 1;
  307.  
  308.         zoomBox . Left    = placeLeft;
  309.         zoomBox . Top    = placeTop;
  310.     }
  311. #endif    /* DO_CLONING */
  312.  
  313.     /* ALWAYS */
  314.     {
  315.         struct TagItem *TagList = (struct TagItem *)TagParams;
  316.  
  317.         while(item = NextTagItem(&TagList))
  318.         {
  319.             switch((ULONG)item -> ti_Tag)
  320.             {
  321.                 case LA_Menu:
  322.  
  323.                     if(!menu)
  324.                     {
  325.                         handle -> IDCMP |= IDCMP_MENUPICK;
  326.  
  327.                         menu = (struct Menu *)item -> ti_Data;
  328.                     }
  329.  
  330.                     break;
  331.  
  332.                 case LAWN_SmartZoom:
  333.  
  334.                     SmartZoom = item -> ti_Data;
  335.  
  336.                     if(!SmartZoom)
  337.                         break;
  338.  
  339.                 case LAWN_Zoom:
  340.  
  341.                     if(item -> ti_Data)
  342.                     {
  343.                         if(title && SmartZoom)
  344.                         {
  345.                             STATIC UWORD WhichTable[3] =
  346.                             {
  347.                                 CLOSEIMAGE,
  348.                                 ZOOMIMAGE,
  349.                                 DEPTHIMAGE
  350.                             };
  351.  
  352.                             LONG     Size = 0,i;
  353.                             BOOLEAN  GotIt = TRUE;
  354.                             UWORD     SizeType;
  355.                             Object    *Image;
  356.  
  357.                             if(handle -> Screen -> Flags & SCREENHIRES)
  358.                                 SizeType = SYSISIZE_MEDRES;
  359.                             else
  360.                                 SizeType = SYSISIZE_LOWRES;
  361.  
  362.                             for(i = 0 ; i < 3 ; i++)
  363.                             {
  364.                                 if(Image = NewObject(NULL,SYSICLASS,
  365.                                     SYSIA_Size,    SizeType,
  366.                                     SYSIA_Which,    WhichTable[i],
  367.                                     SYSIA_DrawInfo, handle -> DrawInfo,
  368.                                 TAG_DONE))
  369.                                 {
  370.                                     ULONG Width;
  371.  
  372.                                     GetAttr(IA_Width,Image,&Width);
  373.  
  374.                                     Size += Width;
  375.  
  376.                                     DisposeObject(Image);
  377.                                 }
  378.                                 else
  379.                                     GotIt = FALSE;
  380.                             }
  381.  
  382.                             if(GotIt)
  383.                             {
  384.                                 Size += 8 + TextLength(&handle -> Screen -> RastPort,title,strlen(title)) + 8;
  385.  
  386.                                 zoomBox . Width = Size;
  387.                             }
  388.                             else
  389.                                 zoomBox . Width = width;
  390.                         }
  391.                         else
  392.                             zoomBox . Width = width;
  393.  
  394.                         if(V39)
  395.                         {
  396.                             zoomBox . Left    = -1;
  397.                             zoomBox . Top    = -1;
  398.                         }
  399.                         else
  400.                         {
  401.                             zoomBox . Left    = placeLeft;
  402.                             zoomBox . Top    = placeTop;
  403.                         }
  404.  
  405.                         zoomBox . Height = handle -> Screen -> WBorTop + handle -> Screen -> Font -> ta_YSize + 1;
  406.  
  407.                         zoom = &zoomBox;
  408.                     }
  409.  
  410.                     break;
  411.  
  412.                 case LAWN_UserPort:
  413.  
  414.                     handle -> MsgPort = (struct MsgPort *)item -> ti_Data;
  415.  
  416.                     break;
  417.  
  418.                 case LAWN_HelpHook:
  419.  
  420.                     handle -> HelpHook = (struct Hook *)item -> ti_Data;
  421.  
  422.                     break;
  423.  
  424.                 case LAWN_Left:
  425.  
  426.                     placeLeft = item -> ti_Data;
  427.  
  428.                     break;
  429.  
  430.                 case LAWN_Top:
  431.  
  432.                     placeTop = item -> ti_Data;
  433.  
  434.                     break;
  435.  
  436.                 case LAWN_Parent:
  437.  
  438.                     Parent = (struct Window *)item -> ti_Data;
  439.                     break;
  440.  
  441.                 case LAWN_BlockParent:
  442.  
  443.                     BlockParent = item -> ti_Data;
  444.                     break;
  445.  
  446.                 case LAWN_BelowMouse:
  447.  
  448.                     if((placeLeft = handle -> Screen -> MouseX - (width / 2)) < 0)
  449.                         placeLeft = 0;
  450.  
  451.                     if((placeTop = handle -> Screen -> MouseY - (height / 2)) < 0)
  452.                         placeTop = 0;
  453.  
  454.                     break;
  455.  
  456.                 case LAWN_MaxPen:
  457.  
  458.                     handle -> MaxPen = (LONG)item -> ti_Data;
  459.                     break;
  460.  
  461.                 case LAWN_MoveToWindow:
  462.  
  463.                     handle -> MoveToWindow = (LONG)item -> ti_Data;
  464.                     break;
  465.  
  466.                 case LAWN_AutoRefresh:
  467.  
  468.                     handle -> AutoRefresh = (LONG)item -> ti_Data;
  469.                     break;
  470.  
  471.                 case LAWN_Show:
  472.  
  473.                     MakeVisible = item -> ti_Data;
  474.                     break;
  475.             }
  476.         }
  477.     }
  478.  
  479.     Tags = (struct TagItem *)TagParams;
  480.  
  481.     if(handle -> BackgroundPen && !V39)
  482.     {
  483.         if(NewTags = CloneTagItems(Tags))
  484.         {
  485.             STATIC Tag Filter[] = { WA_SimpleRefresh,TAG_DONE };
  486.  
  487.             FilterTagItems(NewTags,Filter,TAGFILTER_NOT);
  488.  
  489.             Tags = NewTags;
  490.         }
  491.         else
  492.         {
  493. #ifdef DO_MENUS
  494.             LT_DisposeMenu(LocalMenu);
  495. #endif    // DO_MENUS
  496.             return(NULL);
  497.         }
  498.     }
  499.  
  500.     if(Parent)
  501.     {
  502.         WORD    Left,Top,Width,Height,MoveLeft,MoveTop,
  503.             WindowLeft,WindowTop,WindowWidth,WindowHeight;
  504.  
  505.         WindowLeft    = Parent -> LeftEdge + Parent -> BorderLeft;
  506.         WindowTop    = Parent -> TopEdge + Parent -> BorderTop;
  507.         WindowWidth    = Parent -> Width - (Parent -> BorderLeft + Parent -> BorderRight);
  508.         WindowHeight    = Parent -> Height - (Parent -> BorderTop + Parent -> BorderBottom);
  509.  
  510.         LTP_GetDisplayClip(Parent -> WScreen,&Left,&Top,&Width,&Height);
  511.  
  512.         if((MoveLeft = WindowLeft + (WindowWidth - width) / 2) < 0)
  513.             MoveLeft = 0;
  514.  
  515.         if((MoveTop = WindowTop + (WindowHeight - height) / 2) < 0)
  516.             MoveTop = 0;
  517.  
  518.         if(MoveLeft < Left || MoveLeft + width > Left + Width)
  519.             MoveLeft = -1;
  520.  
  521.         if(MoveTop < Top || MoveTop + height > Top + Height)
  522.             MoveTop = -1;
  523.  
  524.         if(MoveTop != -1 && MoveLeft != -1)
  525.         {
  526.             placeLeft    = MoveLeft;
  527.             placeTop    = MoveTop;
  528.         }
  529.     }
  530.  
  531.     if(BlockParent && Parent)
  532.     {
  533.         LT_LockWindow(Parent);
  534.  
  535.         handle -> Parent = Parent;
  536.     }
  537.  
  538.     if(SizeGadget)
  539.         zoom = NULL;
  540.  
  541.     if(handle -> Window = OpenWindowTags(NULL,
  542.         WA_Left,        placeLeft,
  543.         WA_Top,         placeTop,
  544.         WA_Width,        width,
  545.         WA_Height,        height,
  546.         WA_NewLookMenus,    TRUE,
  547.         WA_CustomScreen,    handle -> Screen,
  548.         WA_BackFill,        &handle -> BackfillHook,
  549.         WA_MinWidth,        MinX,
  550.         WA_MinHeight,        MinY,
  551.         WA_MaxWidth,        MaxX,
  552.         WA_MaxHeight,        MaxY,
  553.         WA_SizeGadget,        SizeGadget,
  554.         WA_SizeBBottom,        SizeBBottom,
  555.         WA_SizeBRight,        SizeBRight,
  556.         WA_PointerDelay,    TRUE,
  557.         WA_BusyPointer,        TRUE,
  558.  
  559.         zoom    ? WA_Zoom :            TAG_IGNORE,    zoom,
  560.         !handle -> MsgPort ? WA_IDCMP :     TAG_IGNORE,    IDCMP_REFRESHWINDOW | IDCMP_RAWKEY | IDCMP_ACTIVEWINDOW | IDCMP_INACTIVEWINDOW | IDCMP_MOUSEBUTTONS | IDCMP_CHANGEWINDOW | IDCMP | handle -> IDCMP,
  561.         title    ? WA_Title :            TAG_IGNORE,    title,
  562.         handle -> AmigaGlyph ? WA_AmigaKey :    TAG_IGNORE,    handle -> AmigaGlyph,
  563.         handle -> CheckGlyph ? WA_Checkmark :    TAG_IGNORE,    handle -> CheckGlyph,
  564.     TAG_MORE,Tags))
  565.     {
  566.         font = handle -> RPort . Font;
  567.  
  568.         handle -> RPort = *handle -> Window -> RPort;
  569.  
  570.         LTP_SetFont(handle,font);
  571.  
  572. #ifdef DO_BOOPSI_KIND
  573.         if(handle -> BOOPSIList)
  574.         {
  575.             AddGList(handle -> Window,(struct Gadget *)handle -> BOOPSIList,(UWORD)-1,(UWORD)-1,NULL);
  576.  
  577.             RefreshGList((struct Gadget *)handle -> BOOPSIList,handle -> Window,NULL,(UWORD)-1);
  578.         }
  579. #endif    /* DO_BOOPSI_KIND */
  580.  
  581.         AddGList(handle -> Window,handle -> List,(UWORD)-1,(UWORD)-1,NULL);
  582.  
  583.         RefreshGList(handle -> List,handle -> Window,NULL,(UWORD)-1);
  584.  
  585.         if(NewTags)
  586.         {
  587.             FreeTagItems(NewTags);
  588.  
  589.             NewTags = NULL;
  590.         }
  591.  
  592.         if(V39)
  593.         {
  594.             if(handle -> MaxPen > 0)
  595.             {
  596.                 SetMaxPen(&handle -> RPort,handle -> MaxPen);
  597.                 SetMaxPen(handle -> Window -> RPort,handle -> MaxPen);
  598.             }
  599.         }
  600.  
  601.         GT_RefreshWindow(handle -> Window,NULL);
  602.         LTP_DrawGroup(handle,handle -> TopGroup);
  603.  
  604.         LTP_MoveToWindow(handle);
  605.  
  606.         handle -> Window -> UserData = (APTR)handle;
  607.  
  608.         if(handle -> MsgPort)
  609.         {
  610.             handle -> Window -> UserPort = handle -> MsgPort;
  611.  
  612.             if(!ModifyIDCMP(handle -> Window,IDCMP_CHANGEWINDOW | IDCMP_REFRESHWINDOW | IDCMP_RAWKEY | IDCMP_INACTIVEWINDOW | IDCMP_ACTIVEWINDOW | IDCMP_MOUSEBUTTONS | IDCMP | handle -> IDCMP))
  613.             {
  614.                 handle -> Window -> UserPort = NULL;
  615.  
  616.                 return (NULL);
  617.             }
  618.         }
  619.  
  620.         if(menu)
  621.             SetMenuStrip(handle -> Window,menu);
  622.  
  623.         handle -> Menu = LocalMenu;
  624.  
  625.         handle -> Previous = NULL;
  626.  
  627.         for(i = 0 ; i < handle -> Count ; i++)
  628.         {
  629.             if(handle -> GadgetArray[i])
  630.             {
  631.                 ObjectNode *node;
  632.  
  633.                 if(GETOBJECT(handle -> GadgetArray[i],node))
  634.                 {
  635.                     if(LIKE_STRING_KIND(node) || (node -> Type == INTEGER_KIND))
  636.                     {
  637.                         if(!handle -> Previous)
  638.                             handle -> Previous = handle -> GadgetArray[i];
  639.                     }
  640.                 }
  641.             }
  642.         }
  643. #ifdef DO_CLONING
  644.         if(handle -> CloneExtra)
  645.             ScreenToFront(handle -> Window -> WScreen);
  646. #endif
  647.         if(V39)
  648.             SetWindowPointerA(handle -> Window,NULL);
  649.  
  650.         if(MakeVisible)
  651.         {
  652.             ScreenToFront(handle -> Screen);
  653.  
  654.             if(V39)
  655.             {
  656.                 WORD left,top,width,height;
  657.  
  658.                 LTP_GetDisplayClip(handle->Screen,&left,&top,&width,&height);
  659.  
  660.                 if(handle -> Window -> Width < width)
  661.                     left = (width - handle -> Window -> Width) / 2;
  662.                 else
  663.                     left = 0;
  664.  
  665.                 if(handle -> Window -> Height < height)
  666.                     top = (height - handle -> Window -> Height) / 2;
  667.                 else
  668.                     top = 0;
  669.  
  670.                 if((left = handle -> Window -> LeftEdge - left) < 0)
  671.                     left = 0;
  672.  
  673.                 if((top = handle -> Window -> TopEdge - top) < 0)
  674.                     top = 0;
  675.  
  676.                 ScreenPosition(handle -> Screen,SPOS_MAKEVISIBLE,left,top,left + width - 1,top + height - 1);
  677.             }
  678.         }
  679.     }
  680.     else
  681.     {
  682.         if(handle -> Parent)
  683.         {
  684.             LT_UnlockWindow(handle -> Parent);
  685.  
  686.             handle -> Parent = NULL;
  687.         }
  688.  
  689. #ifdef DO_MENUS
  690.         LT_DisposeMenu(LocalMenu);
  691. #endif    // DO_MENUS
  692.     }
  693.  
  694.     FreeTagItems(NewTags);
  695.  
  696.     return(handle -> Window);
  697. }
  698.  
  699.  
  700. /*****************************************************************************/
  701.  
  702.  
  703. struct Window * __stdargs
  704. LT_Layout(LayoutHandle *handle, STRPTR title,struct IBox *bounds,LONG extraWidth, LONG extraHeight,ULONG IDCMP, UBYTE align, ...)
  705. {
  706.     struct Window    *Result;
  707.     va_list      VarArgs;
  708.  
  709.     va_start(VarArgs,align);
  710.  
  711.     Result = LT_Build(handle,
  712.         LAWN_Title,        title,
  713.         LAWN_Bounds,        bounds,
  714.         LAWN_ExtraWidth,    extraWidth,
  715.         LAWN_ExtraHeight,    extraHeight,
  716.         LAWN_IDCMP,        IDCMP,
  717.         LAWN_AlignWindow,    align,
  718.     TAG_MORE,(struct TagItem *)VarArgs);
  719.  
  720.     va_end(VarArgs);
  721.  
  722.     return(Result);
  723. }
  724.  
  725.  
  726. /*****************************************************************************/
  727.  
  728.  
  729. struct Window * LIBENT
  730. LT_LayoutA(REG(a0) LayoutHandle *handle, REG(a1) STRPTR title,REG(a2) struct IBox *bounds,REG(d0) LONG extraWidth, REG(d1) LONG extraHeight,REG(d2) ULONG IDCMP, REG(d3) UBYTE align, REG(a3) struct TagItem *TagParams)
  731. {
  732.     struct Window *Result;
  733.  
  734.     Result = LT_Build(handle,
  735.         LAWN_Title,        title,
  736.         LAWN_Bounds,        bounds,
  737.         LAWN_ExtraWidth,    extraWidth,
  738.         LAWN_ExtraHeight,    extraHeight,
  739.         LAWN_IDCMP,        IDCMP,
  740.         LAWN_AlignWindow,    align,
  741.     TAG_MORE,TagParams);
  742.  
  743.     return(Result);
  744. }
  745.